def getdata():#爬取多个网页
    count=0
    file = open(r"C:\Users\小姜\Desktop\oppo.txt", "a", encoding="utf-8")
    for i in range(0,100):#获取3272页
        if count % 10 == 0:
            time.sleep(random.random() + 1)
        url="https://club.jd.com/comment/productPageComments.action?callback=fetchJSON_comment98&productId=100020915552&score=0&sortType=5&page="+str(i)+"&pageSize=10&isShadowSku=0&rid=0&fold=1"
        html=geturl(url)#保存获取到的网页源码
        # 逐一解析
        re_model=re.compile(r'<class="">:\"([^"]+)\",\"(?:creationTime|vcontent)\"',re.S)
        data = re_model.findall(html)
        for i in data:
            count+=1
            file.write("%d :" % count)
            file.write(i + "\n")
            file.write("\n")

getdata()